import service from "@/service/http.interceptor";

/**
 * 发送短信
 */
export const smsCode = (params) => {
	return service.request({
		method: 'get',
		url: '/admin/mobile/shopUserSendSmsCode/' + params.phone,
		custom: {
			loading: true
		}
	})
}

/**
 * 用户注册
 */
export const register = (data) => {
	return service.request({
		method: 'post',
		url: 'shop_user/user/c/register',
		data,
		custom: {
			loading: true
		}
	})	
}


/**
 * 短信验证码登录
 */
export const loginSms = (mobile, smsCode) => {
	let params = {
		mobile: mobile,
		grant_type:'mobile',
		scope:'server',
	}
	const basicAuth = "Basic c2hvcF91c2VyOnNob3BfdXNlcg=="
	return service.request({
		method: 'post',
		url: '/auth/oauth2/token',
		params: params,
		header:{
			Authorization: basicAuth
		},
		custom: {
			isToken: false,
			loading: true
		},
	})	
}

/**
 * 获取用户信息
 */
export const getUserInfo = (params) => {
	return service.request({
		method: 'get',
		url: 'shop_user/user/c/info',
		params,
		custom: {
			loading: true
		}
	})	
}

/**
 * 微信授权
 */
export const getPhone = (code) => {
	return service.request({
		method: 'get',
		url: `shop_user/user/c/getWechatPhone/${code}`,
		custom: {
			loading: true
		}
	})	
}